package com.hlt.shuiliting.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.hlt.shuiliting.database.DBUtil;
import com.hlt.shuiliting.valuebean.GongChengXMBean;

public class GongChengXMDAO {
	
	private int pageCount;

	public List list() {
		String sql = "select * from GongChengXM ";
		Object[] params = null;
		
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet();
		myDB.closed();
		
		return list;
	}
	
	public List list(int pageSize, int pageNum) {
		String sql = "select * from GongChengXM";
		Object[] params = null;
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet(pageSize, pageNum);
		pageCount = myDB.getPageCount();
		myDB.closed();
		
		return list;
	}
	
	public List list(String XiangMuDM, String XiangMuMC, String GongChengLB, String XiangMuSD, String XiangMuJSDW) {
		/**
		String sql = "select * from GongChengXM where " +
				"XiangMuDM = ?, XiangMuMC = ?, GongChengLB = ?, XiangMuSD = ?, XiangMuJSDW = ? ";
		Object[] params = {XiangMuDM, XiangMuMC, GongChengLB, XiangMuSD, XiangMuJSDW};
		*/
		String sql = "select * from GongChengXM where XiangMuDM = '" + XiangMuDM + "'and "
			+ "XiangMuMC = '" + XiangMuMC + "'and " + "GongChengLB = '" +  GongChengLB + "'and " + "XiangMuSD = '" +  XiangMuSD + "'and " + "XiangMuJSDW = '" + XiangMuJSDW + "'";
		Object[] params = null;
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet();
		myDB.closed();
		return list;
	}
	
	public int getPageCount() {
		return pageCount;
	}
	
	public Map view(int id) {
		List list = null;
		Object[] params = null;
		String sql = "select * from GongChengXM where ID = " + id;
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		list = myDB.getResultSet();
		Map map = (Map)list.get(0);
		myDB.closed();
		
		return map;
		
	}
	
	public int insert(GongChengXMBean gongChengXMBean) {
		String sql = "insert into GongChengXM values (seq_GongChengXM.nextVal,'" + gongChengXMBean.getZhuangTai() + "',to_date('" 
			+ gongChengXMBean.getJiLuSJ() + "','yyyy-mm-dd'),'" + gongChengXMBean.getLuRuR() + "','" + gongChengXMBean.getXiangMuDM()
			+ "','" + gongChengXMBean.getXiangMuMC() + "','" + gongChengXMBean.getGongChengLB() + "','" + gongChengXMBean.getXiangMuFRMC()
			+ "','" + gongChengXMBean.getXiangMuSD() + "','" + gongChengXMBean.getXiangMuZGBM() + "','" + gongChengXMBean.getGongChengGM()
			+ "','" + gongChengXMBean.getGongChengZTZ() + "',to_date('" + gongChengXMBean.getJiHuaKGRQ() + "','yyyy-mm-dd'),to_date('" + gongChengXMBean.getJiHuaJGRQ()
			+ "','yyyy-mm-dd'),'" + gongChengXMBean.getXiangMuJSDW() + "','" + gongChengXMBean.getXiangMuFZRXM() + "','" + gongChengXMBean.getJiShuFZRXM()
			+ "',to_date('" + gongChengXMBean.getShiJiKGRQ() + "','yyyy-mm-dd'),to_date('" + gongChengXMBean.getShiJiJGRQ() + "','yyyy-mm-dd'),'" + gongChengXMBean.getDiFangZFFZR()
			+ "','" + gongChengXMBean.getZhuGuanBMFZR() + "','" + gongChengXMBean.getJianSheDWFZR() + "','" + gongChengXMBean.getFaRenPZWH()
			+ "','" + gongChengXMBean.getFaRenDB() + "','" + gongChengXMBean.getFaRenJSFZR() + "','" + gongChengXMBean.getFaRenXCGLY()
			+ "','" + gongChengXMBean.getLaiYuanLX() + "','" + gongChengXMBean.getXiangMuTZQY() + "','" + gongChengXMBean.getZhongYangZJ()
			+ "','" + gongChengXMBean.getShengPeiT() + "','" + gongChengXMBean.getShiPeiT() + "','" + gongChengXMBean.getXianPeiT()
			+ "','" + gongChengXMBean.getTouziFZJ() + "','" + gongChengXMBean.getLeiJiDWZYZJ() + "','" + gongChengXMBean.getLeiJiDWSPT()
			+ "','" + gongChengXMBean.getLeiJiDWShiPT() + "','" + gongChengXMBean.getLeiJiDWXPT() + "','" + gongChengXMBean.getLeiJiDWTZZJ()
			+ "','" + gongChengXMBean.getJianSheYDPZS() + "','" + gongChengXMBean.getGuoYouTDGHDS() + "','" + gongChengXMBean.getGuoYouTDSYZ()
			+ "','" + gongChengXMBean.getJianSheNRJJ() + "')";
		Object[] params = null;
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		int updateCount = myDB.getUpdateCount();
		myDB.closed();
		
		return updateCount;
		
	}
	
	public int update(GongChengXMBean gongChengXMBean) {
		String sql = "update GongChengXM set ZhuangTai ='" + gongChengXMBean.getZhuangTai() + "',JiLuSJ ='" 
		+ gongChengXMBean.getJiLuSJ() + "', LuRuR = '" + gongChengXMBean.getLuRuR() + "', XiangMuDM = '" + gongChengXMBean.getXiangMuDM()
		+ "', XiangMuMC = '" + gongChengXMBean.getXiangMuMC() + "', GongChengLB = '" + gongChengXMBean.getGongChengLB() + "', XiangMuFRMC = '" + gongChengXMBean.getXiangMuFRMC()
		+ "', XiangMuSD = '" + gongChengXMBean.getXiangMuSD() + "', XiangMuZGBM = '" + gongChengXMBean.getXiangMuZGBM() + "', GongChengGM = '" + gongChengXMBean.getGongChengGM()
		+ "', GongChengZTZ = '" + gongChengXMBean.getGongChengZTZ() + "', JiHuaKGRQ = '" + gongChengXMBean.getJiHuaKGRQ() + "', JiHuaJGRQ = '" + gongChengXMBean.getJiHuaJGRQ()
		+ "', XiangMuJSDW = '" + gongChengXMBean.getXiangMuJSDW() + "', XiangMuFZRXM = '" + gongChengXMBean.getXiangMuFZRXM() + "', JiShuFZRXM = '" + gongChengXMBean.getJiShuFZRXM()
		+ "', ShiJiKGRQ = '" + gongChengXMBean.getShiJiKGRQ() + "', ShiJiJGRQ = '" + gongChengXMBean.getShiJiJGRQ() + "', DiFangZFFZR = '" + gongChengXMBean.getDiFangZFFZR()
		+ "', ZhuGuanBMFZR = '" + gongChengXMBean.getZhuGuanBMFZR() + "', JianSheDWFZR = '" + gongChengXMBean.getJianSheDWFZR() + "', FaRenPZWH = '" + gongChengXMBean.getFaRenPZWH()
		+ "', FaRenDB = '" + gongChengXMBean.getFaRenDB() + "', FaRenJSFZR = '" + gongChengXMBean.getFaRenJSFZR() + "', FaRenXCGLY = '" + gongChengXMBean.getFaRenXCGLY()
		+ "', LaiYuanLX = '" + gongChengXMBean.getLaiYuanLX() + "', XiangMuTZQY = '" + gongChengXMBean.getXiangMuTZQY() + "', ZhongYangZJ = '" + gongChengXMBean.getZhongYangZJ()
		+ "', ShengPeiT = '" + gongChengXMBean.getShengPeiT() + "', ShiPeiT = '" + gongChengXMBean.getShiPeiT() + "', XianPeiT = '" + gongChengXMBean.getXianPeiT()
		+ "', TouziFZJ = '" + gongChengXMBean.getTouziFZJ() + "', LeiJiDWZYZJ = '" + gongChengXMBean.getLeiJiDWZYZJ() + "', LeiJiDWSPT = '" + gongChengXMBean.getLeiJiDWSPT()
		+ "', LeiJiDWShiPT = '" + gongChengXMBean.getLeiJiDWShiPT() + "', LeiJiDWXPT = '" + gongChengXMBean.getLeiJiDWXPT() + "', LeiJiDWTZZJ = '" + gongChengXMBean.getLeiJiDWTZZJ()
		+ "', JianSheYDPZS = '" + gongChengXMBean.getJianSheYDPZS() + "', GuoYouTDGHDS = '" + gongChengXMBean.getGuoYouTDGHDS() + "', GuoYouTDSYZ = '" + gongChengXMBean.getGuoYouTDSYZ()
		+ "', JianSheNRJJ = '" + gongChengXMBean.getJianSheNRJJ() + "'where ID ='" + gongChengXMBean.getID() + "'";
		Object[] params = null;
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		int updateCount = myDB.getUpdateCount();
		myDB.closed();
		
		return updateCount;
		
	}
	public int delete(int id) {
		String sql = "delete from GongChengXM where ID = ?";
		Object[] params = {id};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		int updateCount = myDB.getUpdateCount();
		myDB.closed();
		
		return updateCount;
		
	}
}
